package org.example.maven.controller;

import org.example.maven.annotation.ReadOnlyMode;
import org.example.maven.pojo.Result;
import org.example.maven.utils.AliyunUtils;
import org.example.maven.utils.uploadImg;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping("/upload")
public class UploadImgController {
    @PostMapping("/img")
    @ReadOnlyMode
    //上传藏品图片
    @PreAuthorize("hasAnyAuthority('collection:add')")
    public Result uploadImg(@RequestParam("file") MultipartFile file) throws Exception {
        return Result.success("图片上传成功",AliyunUtils.uploadFile(file));
    }

}
